package com.credithc.signature.manager.controller.api;

import com.alibaba.fastjson.JSONObject;
import com.credithc.signature.common.to.DataPushResult;
import com.credithc.signature.manager.ro.DataPushRo;
import com.credithc.signature.manager.service.DataPushApiServie;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @desc: 对外提供查询统计信息接口<br />
 * @author: Jingbo Hu<br/>
 * @time：2020年05⽉18⽇<br/>
 * @version：v1.0.0<br>
 */
@RestController
@RequestMapping("/api/scs/v2")
@Slf4j
public class DataPushApiController {

    @Autowired
    DataPushApiServie dataPushApiServie;

    /**
     * 查询统计信息
     */
    @GetMapping("/datapush/count")
    public Object dataPush(DataPushRo dataPushRo) {
        log.info("[数据推送接口]请求体信息={}", JSONObject.toJSONString(dataPushRo));
        DataPushResult dataPushResult = dataPushApiServie.verifyRequestBody(dataPushRo);
        if (!dataPushResult.getIsSuccess()) {
            return dataPushResult.getResultMsg();
        }
        return dataPushApiServie.listDataInfos(dataPushRo);
    }

}
